package com.ay272.ssh2.meal;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.mail.javamail.MimeMessageHelper;

/**
 * Created by java on 2016/5/22.
 */
public class TextSpringMeil {
    public static void main(String[] args) throws  Exception {
        ApplicationContext ac= new ClassPathXmlApplicationContext("applicationContext.xml");
        JavaMailSenderImpl mail = (JavaMailSenderImpl) ac.getBean("mailSender");
        MimeMessageHelper mmh = new MimeMessageHelper(mail.createMimeMessage());
        mmh.setSubject("Spring java mail");
        mmh.setText("我在做练习");
        mmh.setTo("asdasdbutvich@foxmail.com");
        mmh.setFrom("asdasdbutvich@foxmail.com");
        mail.send(mmh.getMimeMessage());
        System.out.println("发送成功");
    }
}
